package com.newly.common.base.exception.handler;

import com.newly.common.base.constants.CodeConstant;
import com.newly.common.base.entity.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class GlobalExceptionHandle {

    @ExceptionHandler(Throwable.class)
    public R newlyExceptionHandler(Throwable throwable) {
        String message = throwable.getMessage();
        return R.fail(CodeConstant.FAILED, null, message);
    }
}
